package com.warehouse.service.impl;

import com.warehouse.dto.Ware;
import com.warehouse.dto.Warehousing;
import com.warehouse.dto.Warelike;
import com.warehouse.entity.ProType;
import com.warehouse.mapper.ProTypeMapper;
import com.warehouse.mapper.ProductMapper;
import com.warehouse.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    //注入产品的mapper层
    @Autowired
    private ProductMapper productMapper;


    /**
     * 入库管理的
     * @param
     * @return
     */
    @Override
    public List<Warehousing> selectLikePro(String wareId, String supId, String proId, String proName){
        String wareId1=null;
        String supId1=null;
        String proId1=null;
        String proName1=null;
        if (wareId!=null){
            wareId1="%"+wareId+"%";
        }
        if (supId!=null){
            supId1="%"+supId+"%";
        }
        if (proId!=null){
            proId1="%"+proId+"%";
        }
        if (proName!=null){
            proName1="%"+proName+"%";
        }


        List<Warehousing> list=  productMapper.selectOutWare(proId1,supId1,wareId1,proName1);
        return list;

    }

    /**
     * 出库管理
     * @param
     * @return
     */
    @Override
    public List<Warehousing> selectOutWare(String wareId, String supId, String proId, String proName) {

        String wareId1=null;
        String supId1=null;
        String proId1=null;
        String proName1=null;
        if (wareId!=null){
           wareId1="%"+wareId+"%";
        }
        if (supId!=null){
            supId1="%"+supId+"%";
        }
        if (proId!=null){
            proId1="%"+proId+"%";
        }
        if (proName!=null){
            proName1="%"+proName+"%";
        }


        List<Warehousing> list=  productMapper.selectOutWare(proId1,supId1,wareId1,proName1);
        return list;


    }

    /**
     * 对商品进行入库
     * @param proId
     * @return
     */
    @Override
    public boolean inWarePro(String proId) {
        int i=productMapper.inWarePro(proId);
        if (i>-1){
            return true;
        }
        return false;
    }

    /**
     * 对商品进行出库
     * @param proId
     * @return
     */
    @Override
    public boolean outWarePro(String proId) {
        int i=productMapper.outWarePro(proId);
        if (i>-1){
            return true;
        }
        return false;
    }




}
